import req from "../../tool/axios"
import {IDParams} from "../../tool/types";

///user/list

export interface GetUserListParams {
    id?: number
    page: number
    size: number
    username?: string
}

export interface UpdateCoinParams {
    id: number
    coin: number
    intro: string
}

export interface UpdateSettingParams {
    id: number
    vip: number
    name: string
    lock: number
    role_id: number
}

const User = {
    GetUserList: (data: GetUserListParams) => req.GetForm('/admin/admin/user/list', data, {}), //获取用户列表
    GetAllRole: () => req.GetForm('/admin/admin/user/role', {}, {}), //获取所有的角色列表
    UpdateCoin: (data: UpdateCoinParams) => req.PutJson('/admin/admin/user/coin', data, {}), //变更积分记录，充值或者扣除。
    UpdateSetting: (data: UpdateSettingParams) => req.PutJson('/admin/admin/user/setting', data, {}), //修改用户的基本属性
    GetCoinHistory: (data: { id: number }) => req.GetForm('/admin/admin/user/history', data, {}), //获取指定用户的积分变更记录
    GetRoleMenuList: (data: { id: number }) => req.GetForm('/admin/admin/user/role_menu', data, {}), //获取指定权限角色的菜单权限列表
}

const Code = {
    GetAllRegisterCode: () => req.GetForm('/admin/admin/code/all', {}, {}), //获取全部的注册码
    DeleteCode: (data: IDParams) => req.DeleteForm('/admin/admin/code/delete', data, {}), //删除指定ID的注册码
    CreateCode: (data: IDParams) => req.PostJson('/admin/admin/code/create', data, {}), //创建指定权限角色的注册码
}

export interface SettingProductParams {
    key: string
    vip_1: number
    vip_2: number
    vip_3: number
    vip_4: number
    vip_5: number
    vip_6: number
}

const Product = {
    GetAllProduct: () => req.GetForm('/admin/admin/product/all', {}, {}), //获取所有的商品列表
    SettingProduct: (data: SettingProductParams) => req.PutJson('/admin/admin/product/setting', data, {}), //设置商品的价格
}
export default {
    User, Code, Product
}